﻿//-----------------------------------------------------------------------
// <copyright file="LogExecutionAttribute.cs" company="OverrideThis">
//     Copyright (c) 2010 OverrideThis.com
// </copyright>
//-----------------------------------------------------------------------
namespace OverrideThis.ContactManager.WebSite.Infrastructure.ActionFilters
{
    using System;
    using System.Web.Mvc;
    using log4net;

    public class LogExecutionAttribute : ActionFilterAttribute
    {
        private readonly ILog logger = LogManager.GetLogger("Default");

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            string message = string.Format("Action Executed {0}.{1} - {2}",
                filterContext.RouteData.Values["Controller"],
                filterContext.RouteData.Values["Action"],
                DateTime.Now);
            logger.Info(message);
        }

    } 
}